/**
 * Copyright (c) 2024 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
import vpn from '@ohos.net.vpn';
import protocolModel from './ProtocolModel';

/**
 * extend system VpnConig
 */

export default class VpnConfig implements vpn.VpnConfig {
  alias?: string | undefined //名称
  type: number = protocolModel.IKEV2_IPSEC_MSCHAPv2 //类型 默认为IKEV2_IPSEC_MSCHAPv2

  addresses: Array<vpn.LinkAddress>; // 父接口中的adress
  routes?: Array<vpn.RouteInfo>; // 父接口中的路由信息
  dnsAddresses?: Array<string>; // 父接口中dns
  searchDomains?: Array<string>; // 父接口中搜索域

  ipsecIdentifier?: string | undefined // ipsec标识符
  ipsecSecret?: string | undefined // ipsec预共享密钥
  l2tpSecret?: string | undefined // L2TP 密钥

  username?: string | undefined // 登录用户名
  password?: string | undefined // 登录密码
  saveLogin: boolean = false // 是否记住登录用户名与密码

  ipsecUserCert?: string | undefined // 用户证书alias
  ipsecCaCert?: string | undefined // ca证书alias
  ipsecServerCert?: string | undefined // server证书alias

  // openvpn 特有属性
  ovpnConfigFileName?:string | undefined // openVpn 文件名
  ovpnConfigContent?: string | undefined // openVpn config 明文
  ovpnConfig?: string | undefined // openVpn config base64内容

  ovpnAuthType:number = 0 // ovpen认证方式

  ovpnProtocolFileRaw?:string // 协议raw数据
  ovpnProtocol:number = 0 // 协议类型 0:tcp 1:udp

  ovpnAddressPortFileRaw?:string // 地址端口raw数据
  ovpnAdressStr?:string | undefined // 地址字符串 仅openvpn使用
  ovpnPortStr?:string | undefined // 端口字符串 仅openvpn使用

  ovpnCaCertFileRaw?:string // CA证书在config中的raw数据
  ovpnCaCert?:string // CA证书数据
  ovpnCaCertFileName?:string | undefined // openVpn CA证书 文件名

  ovpnUserCertFileRaw?:string // User证书在config中的raw数据
  ovpnUserCert?:string // User证书raw数据
  ovpnUserCertFileName?:string | undefined // openVpn USER证书 文件名

  ovpnPrivateKeyFileRaw?:string // 私钥在config中的raw数据
  ovpnPrivateKey?:string // 私钥raw数据
  ovpnPrivateKeyFileName?:string | undefined // openVpn 私钥 文件名

  paskpass:string | undefined // 私钥密码

  ovpnUserPassFileRaw?:string // userpass数据
  ovpnUsername?:string | undefined // openVpn 用户名
  ovpnPassword?:string | undefined // openVpn 密码

  ovpnProxyHostFileRaw?:string // ho
  // strport数据
  ovpnProxyHost?:string //ovpn host
  ovpnProxyPort?:string //ovpn port

  ovpnProxyUserPassFileRaw?:string // userpass数据
  ovpnProxyUser?:string //ovpn user
  ovpnProxyPass?:string //ovpn pass

  // 以下为hap侧使用属性 服务端可以忽略
  id?: number | undefined //数据库自增长ID
  connectTime?: number | undefined // 连接时间 用于列表排序
  ipsecUserCertIndex: number = 0 // 用户证书选择index
  ipsecCaCertIndex: number = 0 // ca证书选择index
  ipsecServerCertIndex: number // server证书选择index
}







